package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.UserSalesInfo;
import com.topscore.uke.mvp.contractors.GetUserSaleInfoModel;
import com.topscore.uke.mvp.contractors.GetUserSalesContractor;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.utils.UserInfoManager;

public class GetUserSaleInfoPresenter implements GetUserSalesContractor, GetUserSalesContractor.Presenter {
    private View mView;
    private Model mModel;

    public GetUserSaleInfoPresenter(View view) {
        this.mView = view;
        this.mModel = new GetUserSaleInfoModel(new Model.CallBack() {
            @Override
            public void onSuccess(BaseResponse<UserSalesInfo> response) {
                mView.onGetUserSalesInfoSuccess(response.getData());
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                mView.onFail(errorCode, errorMessage);
            }

            @Override
            public void onComplete() {
                mView.onLoadFinished();
            }
        });
    }

    @Override
    public void getUserSaleInfo() {
        mView.onLoading("");
        mModel.getData(UserInfoManager.getUserInfo().getLoginName());
    }
}
